using Microsoft.VisualStudio.TestTools.UnitTesting;
using NQueries.TestSupport;
using Rhino.Mocks;

namespace NQueries.Data.Test
{
    [TestClass]
    public class UnitOfWorkTest
    {
        public TestContext TestContext { get; set; }

        [TestMethod]
        public void CommitReturnValueTest()
        {
            IDataContext dataContext = MockTools.StrictInject<IDataContext>();

            using (MockTools.Record())
            {
                Expect.Call(dataContext.SaveChanges()).Return(3);
                Expect.Call(dataContext.Dispose);
            }

            using (MockTools.Playback())
                using (IUnitOfWork target = UnitOfWork.Begin())
                    Assert.AreEqual(3, target.Commit());
        }

        [TestInitialize]
        public void TestInitialize() { MockTools.Reset(); }

        #region Nested type: Test

        public class Test {}

        #endregion
    }
}